package webreg.model.container;

import java.util.Iterator;
import java.util.Vector;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import webreg.model.Club;


/** This class wraps multiple 
 * clubs in one container class for persistence.
 * 
 * @author STKNOLL
 */
@XmlRootElement(name = "clubContainer")
public class ClubContainer {

	/** Vector containing the clubs */
	private Vector<Club> mClubs;

	/** Constructor of a club container */
	public ClubContainer() {
		mClubs = new Vector<Club>();
	}
	
	/** Constructor of an club container
	 * 
	 * @param clubs The clubs to store.
	 */
	public ClubContainer(Vector<Club> clubs) {
		mClubs = clubs;
	}
	
	/** Copy constructor for club container
	 * 
	 * Private copy constructor for a club container
	 * 
	 * @param toCopy The club container to copy
	 */
	public ClubContainer (ClubContainer toCopy) {
		this(toCopy.mClubs);
	}
	
	/** Implementation of the equals method.
	 * 
	 * @param toCompare The club container to compare with
	 * @return True, if club matches
	 */
	public boolean equals(ClubContainer toCompare) {
		Iterator<Club> iter = this.mClubs.iterator();
		Iterator<Club> iter2 = toCompare.mClubs.iterator();
		for (; iter.hasNext() && iter2.hasNext(); ) {
			Club club1 = (Club)iter.next();
			Club club2 = (Club)iter2.next();
			if (club1.equals(club2) == false) return false;
		}
		return true;
	}

		
	/** Sets the clubs that are stored in the container
	 * 
	 * @param clubs The clubs to hold in the container
	 */
	public void setClubs(Vector<Club> clubs) {
		mClubs = clubs;
	}

	/** Gets the stored clubs of the container
	 * 
	 * @return The clubs stored in the container.
	 */
	@XmlElement(name = "club")	
	public Vector<Club> getClubs() {
		return mClubs;
	}
}
